<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta name="author" content="小袁同学,1971788445@qq.com,广州新华学院">
  <meta name="Keywords" content="小袁博客,小袁Java学习站,小袁Java学习平台,文章,博客,小袁博客,article,blog">
  <meta name="description" content="小袁博客,小袁Java学习站,小袁Java学习平台,文章,博客,小袁博客,article,blog,分享Java相关的知识和经验以及各大框架的项目开发提供Java学习的圈子">
  <meta http-equiv="content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  <link rel="shortcut icon" href="/static/img/favicon.ico">
  <!-- 基础样式库 -->
  <link rel="stylesheet" href="/static/css/bootstrap.css"/>
  <link rel="stylesheet" href="/static/css/font-awesome.css"/>
  <link rel="stylesheet" href="/static/css/animate.css"/>
  <!-- hplus样式库 -->
  <link rel="stylesheet" href="/static/css/hplus.css"/>
  <!-- 公共样式 -->
  <link rel="stylesheet" href="/static/css/customer/common.css"/>
  <!-- 自定义图标库 -->
  <link rel="stylesheet" type="text/css" href="/static/css/xy-iconfont.css"/>
  <!-- 页脚样式 -->
  <link rel="stylesheet" href="/static/css/customer/footer&cbl.css"/>
  <!-- 导航栏样式 -->
  <link rel="stylesheet" href="/static/css/customer/header.css"/>
  <!-- 侧边信息样式 -->
  <link rel="stylesheet" href="/static/css/sideBar/sidebar.css"/>
  <script type="text/javascript" src="/static/js/jquery-1.11.3.js"></script>
  <script type="text/javascript" src="/static/js/bootstrap.js"></script>
  <!-- 模板 -->
  <script type="text/javascript" src="/static/js/customer/template.js"></script>
  <!-- 音乐播放器样式 -->
  <link rel="stylesheet" href="/static/css/customer/player.min.css"/>
  <!-- 音乐播放器JS -->
  <script type="text/javascript" src="/static/js/customer/player.min.js"></script>
  <!-- 本页样式 -->
  <link rel="stylesheet" type="text/css" href="/static/css/customer/home.css"/>
  <!-- element ui -->
  <link rel="stylesheet" href="/static/css/element-ui.css">
  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="/static/js/vue.js"></script>
  <script src="/static/js/element-ui.js"></script>
  <script src="/static/js/httpVueLoader.js"></script>
  <title>小袁博客</title>
  <style type="text/css">
    /* 分页样式 */
    .el-pagination__jump {
      color: #E6A23C;
      font-weight: bold;
    }
  </style>
</head>
<body>
<div id="main" v-cloak>
  <!-- 导航栏 -->
  <xy-navbar ref="xyNavbar" :user-info="userInfo"></xy-navbar>
<!--  <div th:insert="common/common::header"></div>-->
  <!-- 导航栏 -->

  <!-- 主体内容区域 -->
  <div class="gray-bg top-navigation">
    <div id="wrapper">
      <div id="page-wrapper" class="home_bg">
        <div class="wrapper wrapper-content">
          <div class="container-fluid">
            <div class="col">
              <div class="col-lg-8 col-md-8 col-xs-12">
                <!-- 文章列表 -->
                <div class="col-md-12"
                     v-loading="loading"
                     element-loading-text="拼命加载中"
                     element-loading-spinner="el-icon-loading"
                     element-loading-background="rgba(0, 0, 0, 0.8)">

                  <!-- 条件筛选 -->
                  <div class="block condition">
                    <ul class="condition-selected">
                      <li class="selected" @click="findArticleWithCondition('publish_time')">最新发布 <i class="xy-icon xyicon-sort"></i></li>
                      <li @click="findArticleWithCondition('view_count')">最多浏览 <i class="xy-icon xyicon-sort"></i></li>
                      <li @click="findArticleWithCondition('')">最多评论 <i class="xy-icon xyicon-sort"></i></li>
                      <li @click="findArticleWithCondition('like_count')">最多点赞 <i class="xy-icon xyicon-sort"></i></li>
                      <li @click="findArticleWithCondition('collect_count')">最多收藏 <i class="xy-icon xyicon-sort"></i></li>
                      <div>
                        <el-button @click="openArticleSearchDialog()" type="primary" size="small" icon="el-icon-search">
                          文章搜索
                        </el-button>
                      </div>
                    </ul>
                  </div>

                  <!-- 文章列表 -->
                  <div class="xy-article" v-for="(item, index) in articleList">
                    <div class="logo" v-if="item.cover">
                      <img :src="item.cover" alt="封面"/>
                    </div>
                    <div class="article-header" @click="browseArticleDetail(item.number)">
                      <h3>{{ item.title }}</h3>
                      <div class="digest" :style="item.cover === '' ? 'margin-bottom: 10px;' : ''">
                        <p>{{ item.digest }}</p>
                      </div>
                    </div>
                    <div class="footer-info">
                      <span><img :src="item.authorAvatar" alt="用户头像"/></span>
                      <h4>{{ item.authorName }}</h4>
                      <span><i class="xy-icon xyicon-clock"></i> {{ item.publishTime }}</span>
                      <span><i class="xy-icon xyicon-eyes"></i> {{ item.viewCount }}</span>
                      <span><i class="xy-icon xyicon-comment"></i> {{ item.commentCount }}</span>
                      <span><i class="xy-icon xyicon-give-good"> {{ item.likeCount }}</i></span>
                      <span><i class="xy-icon xyicon-collect"> {{ item.collectCount}}</i></span>
                      <el-tag effect="dark" type="danger" size="mini" v-for="(tag, index) in splitTags(item.tags)"
                              :key="index">{{ tag }}
                      </el-tag>
                    </div>
                  </div>

                  <!-- 分页 -->
                  <div class="block" style="text-align:center;margin-top:5px;">
                    <el-pagination background
                                   @current-change="handleCurrentChange"
                                   :hide-on-single-page="true"
                                   :current-page.sync="pageParam.pageIndex"
                                   :page-size="pageParam.pageSize"
                                   :total="pageParam.totalCount"
                                   layout="prev, pager, next, jumper">
                    </el-pagination>
                  </div>

                </div>
                <!-- 文章列表 -->
              </div>
            </div>
            <div class="col">
              <div class="col-lg-4 col-md-4 hidden-xs hidden-sm">
                <!-- 个人资料 -->
                <div class="col-md-12 m-b-md" th:insert="common/commonSidebar::side-personal"></div>
                <!-- 个人资料 -->

                <!-- 搜索 -->
                <div class="col-md-12 m-b-sm padding-l-r-60 opacity-8" th:insert="common/commonSidebar::side-search">

                </div>
                <!-- 搜索 -->

                <!-- 热门文章 -->
                <div class="col-md-12 side-hot padding-l-r-60 opacity-8"
                     th:insert="common/commonSidebar::side-hot"></div>
                <!-- 热门文章 -->

                <!-- 文章档案 -->
                <div class="col-md-12 side-archive padding-l-r-60 opacity-8"
                     th:insert="common/commonSidebar::side-archive"></div>
                <!-- 文章档案 -->

                <!-- 最新文章 -->
                <div class="col-md-12 side-new padding-l-r-60 opacity-8"
                     th:insert="common/commonSidebar::side-new"></div>
                <!-- 最新文章 -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- 文章搜索 -->
  <el-dialog
    :visible.sync="searchDialogVisible"
    width="40%">
    <el-form label-position="top">
      <!-- 问题描述 -->
      <el-form-item label="内容搜索" label-width="120" prop="problem">
        <el-input
          maxlength="40"
          placeholder="请输入要搜索的内容（回车触发有bug，暂时只能点击下面按钮）"
          v-model="articleQueryParam.searchWord"
          clearable
          show-word-limit></el-input>
      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
    <el-button type="danger" icon="el-icon-search" @click="submitArticleSearch()"> 搜 索</el-button>
    </span>
  </el-dialog>

  <!-- 提交建议和问题反馈 -->
  <xy-feedback ref="xyFeedback"></xy-feedback>

  <!-- 页脚 -->
  <div th:insert="common/common::footer"></div>
  <!-- 页脚 -->

  <!-- 右侧工具 -->
  <div th:insert="common/common::right-toolbar"></div>
  <!-- 右侧工具 -->
</div>

<!-- 音乐播放器 -->
<div id="player"></div>
<!-- 引入歌曲列表和配置信息 -->
<script type="text/javascript" src="/static/js/customer/music.js"></script>
<!-- hplus的JS -->
<script type="javascript" src="/static/js/content.min.js"></script>
<script src="/static/js/axios.min.js"></script>
<script type="module">
  $(document).ready(function () {
    $(".condition-selected").on("click", "li", function () {
      $(".condition-selected li").removeClass("selected");
      $(this).addClass("selected");
    });
  });

  // 引入组件
  import article from "../../static/js/api/article.js";
  import feedback from "../../static/js/common/dialog/feedback.js";
  import userOperation from "../../static/js/common/navbar/userOperation.js";

  // 使用httpVueLoader
  Vue.use(httpVueLoader);

  var app = new Vue({
    el: '#main',
    components: {
      'xy-navbar': 'url:/static/component/navbar/index.vue',
      'xy-feedback': 'url:/static/component/dialog/feedback.vue',
    },
    data() {
      return {
        userInfo: {},
        loading: false,
        articleList: [],
        //  分页
        pageParam: {
          pageSize: 7, // 每页大小
          pageIndex: 1, // 当前页数
          totalCount: 0, // 总记录数
        },
        // 搜索框
        searchDialogVisible: false,
        // 条件对象
        articleQueryParam: {
          searchWord: '', // 搜索词
          sortCondition: '', // 排序条件
        },
      }
    },
    methods: {
      // 打开问题反馈框
      openProblemDialog() {},
      // 打开提交建议框
      openSuggestDialog() {},
      // 提交问题反馈
      submitProblemFeedback() {},
      // 提交建议反馈
      submitSuggestFeedback() {},
      // 获取用户数据
      getUserInfo() {},
      // 退出登录
      logout() {},
      // 修改个人信息
      submitEditPersonal() {},
      // 找回密码
      submitFindPassword() {},
      // 修改密码
      submitEditPassword() {},
      // 发送验证码
      sendEmailCode() {},
      // 修改邮箱
      submitEditEmail(){},
      // 发送短信验证码
      sendMobileCode(){},
      // 提交修改号码
      submitEditMobileNumber(){},
      // 翻页
      handleCurrentChange(index) {
        this.pageParam.pageIndex = index
        this.findArticleList()
      },
      // 查询文章
      findArticleList() {
        let param = {
          ...this.articleQueryParam,
          'pageIndex': this.pageParam.pageIndex,
          'pageSize': this.pageParam.pageSize
        }
        article.findArticleList(param).then(res => {
          this.articleList = res.data.list;
          this.pageParam.totalCount = res.data.total;

        }).finally(_ => {
          // 关闭加载
          this.loading = false;
          // 关闭搜索框
          this.searchDialogVisible = false
        })
      },
      // 条件筛选
      findArticleWithCondition(condition) {
        this.articleQueryParam.sortCondition = condition;
        this.findArticleList()
      },
      // 打开搜索框
      openArticleSearchDialog() {
        this.searchDialogVisible = true
      },
      // 提交文章搜索
      submitArticleSearch() {
        // 加载
        this.loading = true;
        this.findArticleList()
      },
      // 浏览详细文章
      browseArticleDetail(number) {
        window.location.href = '/home/article/detail/' + number
      },
      // 文章点赞
      articleLike(index) {
      },
      splitTags(tags) {
        return tags.split(',')
      },
    },
    beforeMount() {
      this.findArticleList();
    },
    created() {
      // 函数覆盖
      this.openProblemDialog = feedback.openProblemDialog();
      this.openSuggestDialog = feedback.openSuggestDialog();
      this.submitProblemFeedback = feedback.submitProblemFeedback();
      this.submitSuggestFeedback = feedback.submitSuggestFeedback();
      // 顶部个人相关方法
      this.getUserInfo = userOperation.getUserInfo();
      this.getUserInfo();
      this.logout = userOperation.logout();
      this.submitEditPersonal = userOperation.submitEditPersonal();
      this.submitFindPassword = userOperation.submitFindPassword();
      this.submitEditPassword = userOperation.submitEditPassword();
      this.sendEmailCode = userOperation.sendEmailCode();
      this.submitEditEmail = userOperation.submitEditEmail();
      this.sendSmsCode = userOperation.sendSmsCode();
      this.submitEditMobileNumber = userOperation.submitEditMobileNumber();
    }
  })
</script>
</body>
</html>
